home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / Points.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  3.8 KB  |  122 lines

  1. /*
  2. //   (C) COPYRIGHT International Business Machines Corp. 1993
  3. //   All Rights Reserved
  4. //   Licensed Materials - Property of IBM
  5. //   US Government Users Restricted Rights - Use, duplication or
  6. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. //
  8.  
  9. //
  10. // Permission to use, copy, modify, and distribute this software and its
  11. // documentation for any purpose and without fee is hereby granted, provided
  12. // that the above copyright notice appear in all copies and that both that
  13. // copyright notice and this permission notice appear in supporting
  14. // documentation, and that the name of I.B.M. not be used in advertising
  15. // or publicity pertaining to distribution of the software without specific,
  16. // written prior permission. I.B.M. makes no representations about the
  17. // suitability of this software for any purpose.  It is provided "as is"
  18. // without express or implied warranty.
  19. //
  20. // I.B.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  21. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I.B.M.
  22. // BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  23. // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  24. // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  25. // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  26. //
  27. // Author:  John Spitzer, IBM AWS Graphics Systems (Austin)
  28. //
  29. */
  30.  
  31. #include "Points.h"
  32.  
  33. #undef offset
  34. #define offset(v) offsetof(Points,v)
  35.  
  36. static InfoItem PointsInfo[] = {
  37. #define INC_REASON INFO_ITEM_ARRAY
  38. #include "Points.h"
  39. #undef INC_REASON
  40. };
  41. #include <malloc.h>
  42.  
  43. PointsPtr new_Points()
  44. {
  45.     PointsPtr this = (PointsPtr)malloc(sizeof(Points));
  46.     CheckMalloc(this);
  47.     new_Vertex((VertexPtr)this);
  48.     SetDefaults((TestPtr)this, PointsInfo);
  49.     this->testType = PointsTest;
  50.     this->primitiveType = GL_POINTS;
  51.     this->size = 1;
  52.     this->vertsPerFacet = 1;
  53.     this->usecPixelPrint = " microseconds per pixel with Points";
  54.     this->ratePixelPrint = " pixels per second with Points";
  55.     this->usecPrint = " microseconds per Point";
  56.     this->ratePrint = " Points per second";
  57.     /* Set virtual functions */
  58.     this->SetState = Points__SetState;
  59.     this->delete = delete_Points;
  60.     this->Layout = Points__Layout;
  61.     this->Copy = Points__Copy;
  62.     this->PixelSize = Points__Size;
  63.     return this;
  64. }
  65.  
  66. void delete_Points(TestPtr thisTest)
  67. {
  68.     PointsPtr this = (PointsPtr)thisTest;
  69.     delete_Vertex(thisTest);
  70. }
  71.  
  72. TestPtr Points__Copy(TestPtr thisTest)
  73. {
  74.     PointsPtr this = (PointsPtr)thisTest;
  75.     PointsPtr newPoints = new_Points();
  76.     FreeStrings((TestPtr)newPoints);
  77.     *newPoints = *this;
  78.     CopyStrings((TestPtr)newPoints, (TestPtr)this);
  79.     return (TestPtr)newPoints;
  80. }
  81.  
  82. float Points__Size(TestPtr thisTest)
  83. {
  84.     PointsPtr this = (PointsPtr)thisTest;
  85.     return this->size * this->size;
  86. }
  87.  
  88. int Points__SetState(TestPtr thisTest)
  89. {
  90.     PointsPtr this = (PointsPtr)thisTest;
  91.  
  92.     /* set parent state */
  93.     if (Vertex__SetState(thisTest) == -1) return -1;
  94.  
  95.     /* set local state */
  96.     if (!this->antiAlias) {
  97.     glDisable(GL_POINT_SMOOTH);
  98.     } else {
  99.     if (this->antiAlias == On) {
  100.         glHint(GL_POINT_SMOOTH_HINT, GL_DONT_CARE);
  101.     } else {
  102.         glHint(GL_POINT_SMOOTH_HINT, this->antiAlias);
  103.     }
  104.     glEnable(GL_POINT_SMOOTH);
  105.     }
  106.     glPointSize(this->size);
  107.     return 0;
  108. }
  109.  
  110. void Points__Layout(VertexPtr thisVertex)
  111. {
  112.     PointsPtr this = (PointsPtr)thisVertex;
  113.     int windowDim = min(this->environ.windowWidth, this->environ.windowHeight);
  114.     this->vertsPerBgnEnd = this->objsPerBgnEnd * this->vertsPerFacet;
  115.     this->facetsPerBgnEnd = this->objsPerBgnEnd;
  116.  
  117.     this->layoutPoints = this->numObjects;
  118.     this->layoutPadding = (2. + this->size + (this->antiAlias!=Off))/
  119.                           (float)windowDim;
  120.     Vertex__Layout(thisVertex);
  121. }
  122.